package pojo;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class ComputerRoom {
    private int id;
    private String roomName;
    private int computerNumber;
    private String manager;
    private String location;
    private String buildTime;
    private int state;

    public String toString() {
        String state = "";
        switch(this.state) {
        case 0:
        	state = "使用";
        	break;
        case 1:
        	state = "空闲";
        	break;
        case 2:
        	state = "维护";
        	break;
        }
        String dateTimeStr = "2025-06-09 14:30:00";
        // 定义输入日期时间的格式
        SimpleDateFormat inputFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        // 定义要输出的年月日格式
        SimpleDateFormat outputFormat = new SimpleDateFormat("yyyy-MM-dd");
        String buildTime = "";
        try {
            Date date = inputFormat.parse(dateTimeStr);
            buildTime = outputFormat.format(date);
        } catch (ParseException e) {
            e.printStackTrace();
        }
    	return "id:"+id+" roomName:"+roomName+" computerNumber:"+computerNumber+" manager:"+manager+" location:"+location+" buildTime:"+buildTime+" state:"+state;
    }
}
